#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool judgeSquareSum(int c) {
        int left = 0, right = sqrt(c);
        while (left <= right)
        {
            if (left * left > c - right * right)
            {
                right--;
            }
            else if (left * left < c - right * right)
            {
                left++;
            }
            else
            {
                return true;
            }
        }
        return false;
    }
};